package com.ruoyi.workbench.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.workbench.domain.WorkTaskItem;
import com.ruoyi.workbench.service.IWorkTaskItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工作任务Controller
 * 
 * @author Guojl
 * @date 2024-07-05
 */
@RestController
@RequestMapping("/task/task")
public class WorkTaskItemController extends BaseController
{
    @Autowired
    private IWorkTaskItemService workTaskItemService;

    /**
     * 查询工作任务详细列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WorkTaskItem workTaskItem)
    {
        startPage();
        List<WorkTaskItem> list = workTaskItemService.selectWorkTaskItemList(workTaskItem);
        return getDataTable(list);
    }

    /**
     * 查询工作任务详细列表
     */
    @GetMapping("/listNoPage")
    public AjaxResult listNoPage(WorkTaskItem workTaskItem)
    {
        return success(workTaskItemService.selectWorkTaskItemList(workTaskItem));
    }

    /**
     * 导出工作任务详细列表
     */
    @Log(title = "工作任务详细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkTaskItem workTaskItem)
    {
        List<WorkTaskItem> list = workTaskItemService.selectWorkTaskItemList(workTaskItem);
        ExcelUtil<WorkTaskItem> util = new ExcelUtil<WorkTaskItem>(WorkTaskItem.class);
        util.exportExcel(response, list, "工作任务详细数据");
    }

    /**
     * 获取工作任务详细详细信息
     */
    @GetMapping(value = "/{taskItemId}")
    public AjaxResult getInfo(@PathVariable("taskItemId") Long taskItemId)
    {
        return success(workTaskItemService.selectWorkTaskItemByTaskItemId(taskItemId));
    }

    /**
     * 新增工作任务详细
     */
    @Log(title = "工作任务详细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkTaskItem workTaskItem)
    {
        return toAjax(workTaskItemService.insertWorkTaskItem(workTaskItem));
    }

    /**
     * 修改工作任务详细
     */
    @Log(title = "工作任务详细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkTaskItem workTaskItem)
    {
        return toAjax(workTaskItemService.updateWorkTaskItem(workTaskItem));
    }

    /**
     * 删除工作任务详细
     */
    @Log(title = "工作任务详细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{taskItemIds}")
    public AjaxResult remove(@PathVariable Long[] taskItemIds)
    {
        return toAjax(workTaskItemService.deleteWorkTaskItemByTaskItemIds(taskItemIds));
    }
}
